<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <form action="">
        <input type="checkbox" value="网球" name="items">网球
        <input type="checkbox" value="台球" name="items">台球
        <input type="checkbox" value="篮球" name="items">篮球
        <input type="checkbox" value="羽毛球" name="items">羽毛球
        <input type="checkbox" value="乒乓球" name="items">乒乓球
        <br>
    </form>
    <button id="checkedAll">全选</button>
    <button id="checkedNo">全不选</button>
    <button id="checkedRev">反选</button>
</body>
<script>
    var checkedAll = document.getElementById('checkedAll');
    checkedAll.onclick = function() {
        var items = document.getElementsByName('items');
        for (var i = 0; i < items.length; i++) {
            items[i].checked = true;
        }
    };
    var checkedNo = document.getElementById('checkedNo');
    checkedNo.onclick = function() {
        var items = document.getElementsByName('items');
        for (var i = 0; i < items.length; i++) {
            items[i].checked = false;
        }
    }
    var checkedRev = document.getElementById('checkedRev');
    checkedRev.onclick = function() {
        var items = document.getElementsByName('items');
        for (var i = 0; i < items.length; i++) {
            items[i].checked = !items[i].checked;
        }
    }
</script>

</html>